package SpaceIT.pages.Admin;

import model.dao.NhanVienDAO;
import model.pojo.NhanVien;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.Validate;

public class DangNhap {

	@Persist
	@Property
	@Validate("required")
	private String TenDN;
	
	@Persist
	@Property
	@Validate("required")
	private String MatKhau;
	@Property
	@Persist
	private String message;
	public String EmptyMessage(){
		message = "";
		return "";
	}
	@ApplicationState
	@Property
    private NhanVien NV;
	@OnEvent(value="submit", component="formDangNhap")
	Object onFormSubmit() 
	{	
		NV = NhanVienDAO.KiemTraDangNhap(this.TenDN, this.MatKhau);
		if(NV.isDangNhap())
		{
			//message ="Đăng Nhập Thất Bại" + NV.getTenDangNhap();
			return ThemSanPham.class;
		}
		message ="Đăng Nhập Thất Bại";
		return null;
	}
	
}
